# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: 进程练习.py
Author: kij
Create Date: 2021/3/9
-------------------------------------------------
"""
import time, os
from multiprocessing import Process


# def task(name):
# 	print('%s i running' % name)
# 	time.sleep(3)
# 	print('%s i done' % name)
#
#
# if __name__ == '__main__':
# 	p = Process(target=task, kwargs={'name': '子进程1'})
# 	p = Process(target=task, args=('子进程1',))
# 	p.start()
# 	print('主')

class TaskTest(Process):
	def __init__(self, name):
		super().__init__()
		self.name = name

	def run(self):
		print('%s i running进程id=%s父进程id=%s' % (self.name, os.getpid(), os.getppid()))
		time.sleep(3)
		print('%s i done进程id=%s父进程id=%s' % (self.name, os.getpid(), os.getppid()))


if __name__ == '__main__':
	p = TaskTest('子进程1')
	p.start()
	print('主进程%s父id=%s' % (os.getpid(), os.getppid()))
